#ifndef STATISTIC_H
#define STATISTIC_H

#include <iostream>

#include "lists/classlist_template.h"

#include "stringparsing/stringparser.h"

using namespace std;

class StatList;

class Statistic
{
	private:
		std::string name, sValue; //Name of the statistic and string value of it.
		std::string sType;
		int iValue;
		int valflag;
		StatList * parentList;
	public:
		Statistic();
		Statistic( const Statistic& st );
		Statistic( const std::string& x, const std::string& y );
		Statistic( const std::string& x, int y );

		void setValue( const std::string& x );
		void setValue( int x );
		void setType( const std::string& t );
		void setName( const std::string& x );

		std::string getsValue() const;
		std::string getType() const;
		int getiValue() const;
		std::string getName() const;

		bool isInt() const;

		bool operator==( const Statistic& s ) const;
		bool operator==( Statistic * s ) const;
		bool operator==( const std::string& s ) const;

		Statistic& operator=( int i );
		Statistic& operator++( int i );
		Statistic& operator--( int i );
		Statistic& operator++();
		Statistic& operator--();
		Statistic& operator+=( int i );
		Statistic& operator-=( int i );
		Statistic& operator+=( const Statistic& s );
		Statistic& operator-=( const Statistic& s );
		int operator+( int i ) const;
		int operator-( int i ) const;

		Statistic& operator=( const std::string& s );
		Statistic& operator=( const char * s );
		Statistic& operator+=( const std::string& s );
		Statistic& operator+=( const char * s );
		std::string operator+( const std::string& s ) const;
		std::string operator+( const char * s ) const;

		Statistic& operator|=( const std::string& s );
		Statistic& operator|=( const char * s );

		operator int() const;
		operator std::string() const;

		std::string toString() const;

		inline StatList * parent() const { return this->parentList; }

		friend class StatList;
};

class StatList
{
	private:
		ClassList<Statistic*> statisticsList;
	public:
		StatList();
		virtual ~StatList();

		Statistic * get( const std::string& statName ) const;

		void set( const std::string& statName, const std::string& sValue );
		void set( const std::string& statName, int iValue );

		Statistic& operator[] ( const std::string& statName );
		const Statistic& operator[] ( const std::string& statName ) const;

		Statistic& operator[] ( unsigned int i ) const;

		unsigned int length() const;

		StatList operator+ ( const StatList& stats ) const;
		StatList& operator+= ( const StatList& stats );

		StatList operator| ( const std::string& ns ) const;
		StatList operator| ( const char * ns ) const;

		StatList combine( const StatList& stats, bool catint = true, bool catstr = false, const std::string& delimiter = " " ) const;
};

#endif // STATISTIC_H
